feat(verifier): policy endpoint latency histogram - #1415
Merged
Conversation
makramkd
previously approved these changes
Sep 9, 2026
tt-cll
force-pushed
the
tt/policy-endpoint-latency
branch
from
September 9, 2026 11:20
52948af to
81b941b
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new histogram bucket range and documentation don’t align with the configured maximum policy request timeout, and the interface change is breaking without clear release/changelog treatment or targeted test coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a new outbound policy-hook latency histogram to complement existing policy outcome counters, enabling visibility into slow-but-not-failing policy endpoint behavior.
Changes:
- Adds
RecordPolicyHTTPRequestDurationtovtypes.MetricLabelerand implements it across noop/fake/mock labelers. - Records policy endpoint call duration (labeled by policy outcome vocabulary) from the gated verifier’s evaluation path.
- Registers a new OTel histogram + view and documents the new metric in the policy hook docs.
File summaries
| File | Description |
|---|---|
| verifier/testutil/metric_labeler.go | Extends noop labeler with the new policy HTTP duration method. |
| verifier/pkg/vtypes/interfaces.go | Adds the new policy HTTP duration method to the MetricLabeler interface. |
| verifier/pkg/policy/gate.go | Records per-call latency and introduces callOutcome outcome mapping for histogram labels. |
| verifier/pkg/monitoring/monitoring.go | Extends fake metric labeler with the new method. |
| verifier/pkg/monitoring/metrics.go | Defines and registers the new histogram instrument, view buckets, and label recording. |
| verifier/pkg/helpers_test.go | Updates local test noop metric labeler to satisfy the extended interface. |
| verifier/internal/mocks/mock_MetricLabeler.go | Updates generated mock to include the new method. |
| verifier/docs/policy_hook.md | Documents the new latency histogram and its label vocabulary. |
Review details
Files not reviewed (1)
- verifier/internal/mocks/mock_MetricLabeler.go: Generated file
- Files reviewed: 7/8 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| sdkmetric.NewView( | ||
| sdkmetric.Instrument{Name: "verifier_policy_http_request_duration_seconds"}, | ||
| sdkmetric.Stream{Aggregation: sdkmetric.AggregationExplicitBucketHistogram{ | ||
| Boundaries: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10}, |
Comment on lines
199
to
203
| req := NewEvaluateRequest(g.verifierID, &tasks[index]) | ||
| start := time.Now() | ||
| verdict, err := g.checker.Evaluate(ctx, req) | ||
| g.messageMetrics(tasks[index].Message).RecordPolicyHTTPRequestDuration(ctx, callOutcome(verdict, err), time.Since(start)) | ||
| out[index] = evaluation{verdict: verdict, err: err} |
Comment on lines
+216
to
+220
| // endpoint took. outcome is one of the monitoring.MessageTransitionOutcomePolicy* constants | ||
| // the stage's transition counter uses; policy_skipped never occurs here because a skipped | ||
| // task makes no call. A slow endpoint that is not yet timing out is invisible on the | ||
| // outcome counters, which is what this histogram is for. | ||
| RecordPolicyHTTPRequestDuration(ctx context.Context, outcome string, duration time.Duration) |
Comment on lines
+352
to
+353
| endpoint that is slow but not yet timing out shows up here first. Buckets run from 1ms to 10s, | ||
| around the per-call timeout. |
tt-cll
force-pushed
the
tt/policy-endpoint-latency
branch
from
September 9, 2026 12:38
81b941b to
12683de
Compare
tt-cll
force-pushed
the
tt/policy-endpoint-latency
branch
from
September 9, 2026 16:12
12683de to
18234fd
Compare
|
Code coverage report:
|
makramkd
approved these changes
Sep 9, 2026
nvsriram
approved these changes
Sep 9, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Testing
Checklist
changelogdirectory)Stack created with GitHub Stacks CLI • Give Feedback 💬